package withdraw

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/setting/client/merchant"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/setting/client/settingtoc"
	"github.com/zeromicro/go-zero/core/logx"
)

var MerchantId int64

type WithdrawEnumLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func MerchantIdGet(svcCtx settingtoc.SettingToC, ctx context.Context) int64 {
	if MerchantId == 0 {
		d, err := svcCtx.GetMerchantId(ctx, &merchant.MerchantToCReq{})
		if err != nil {
			return MerchantId
		}
		MerchantId = d.Data.GetId()
	}
	return MerchantId
}

// 资产模块 - 枚举
func NewWithdrawEnumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WithdrawEnumLogic {
	return &WithdrawEnumLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *WithdrawEnumLogic) WithdrawEnum(req *types.WithdrawEnumReq) (resp *types.WithdrawEnumRes, err error) {
	// todo: add your logic here and delete this line
	resp = &types.WithdrawEnumRes{}
	resp.Channel_type = append(resp.Channel_type, types.WithdrawEnumItem{
		int32(rpc.ChannelType_ChannelTypeBank), "BANK CODE"})
	resp.Channel_type = append(resp.Channel_type, types.WithdrawEnumItem{
		int32(rpc.ChannelType_ChannelTypeEwallet), "E-Wallet"})
	resp.Channel_type = append(resp.Channel_type, types.WithdrawEnumItem{
		int32(rpc.ChannelType_ChannelTypeLocalEwallet), "Local-E-Wallet"})
	resp.Channel_type = append(resp.Channel_type, types.WithdrawEnumItem{
		int32(rpc.ChannelType_ChannelTypePixWallets), "PIX"})
	resp.Channel_type = append(resp.Channel_type, types.WithdrawEnumItem{
		int32(rpc.ChannelType_ChannelTypeUsdtWallets), "USDT"})

	resp.Open_status = append(resp.Open_status, types.WithdrawEnumItem{
		int32(rpc.IsOpen_IsOpenOn), "open"})
	resp.Open_status = append(resp.Open_status, types.WithdrawEnumItem{
		int32(rpc.IsOpen_IsOpenOff), "close"})
	return
}
